<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" id="serach">
    <ul id="p">
    </ul>
    <script>
    var con=document.getElementById("serach")
    var plist=document.getElementsByTagName("ul")[0]
    con.oninput=function(){
    var cb="json_"+Math.random().toString().replace(".","")
    var script=document.createElement("script")
    window[cb]=function (e){
       console.log(e)
       var html=""
       e.g.forEach(item => {
        html+= `<a href="https://www.baidu.com/s?wd=${item.q}"><li>${item.q}</li></a>`
    });
    plist.innerHTML=html;
    }
    script.src=`https://www.baidu.com/sugrec?prod=pc&wd=${con.value}&cb=${cb}`
    // fn()
    document.body.appendChild(script)
    script.remove()
    }
    </script>

</body>
</html>